<?php  
class ControllerModuleLanguage extends Controller {
	protected function index() {
    	
		$this->data['lang_current'] = $this->session->data['language'];
		
		$connection = 'NONSSL';
		if (isset($this->request->get['_route_'])) {
			$route = $this->request->get['_route_'];
			if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
				$connection = 'SSL';
			}
		} else {
			$route = '';
		}
		
		$this->load->model('localisation/language');
		$this->data['languages'] = array();
		$results = $this->model_localisation_language->getLanguages();
		
		foreach ($results as $result) {
			if ($result['status']) {
				$this->data['languages'][] = array(
					'name'  => $result['name'],
					'code'  => $result['code'],
					'image' => $result['image'],
					'href'  => $this->url->linkLang($result['code'], $route, $connection)
				);	
			}
		}
			
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/language.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/language.tpl';
		} else {
			$this->template = 'default/template/module/language.tpl';
		}
		
		$this->render();
	}
}
?>